package behaviour.creator;

import agent.CreatorAgent;
import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

public class ReceiveStartStopBehaviour extends CyclicBehaviour {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5584495158782248485L;
	
	@Override
	public void action() {
		// Matching avec les messages d'updates
		MessageTemplate mt = MessageTemplate.MatchConversationId("start-stop");
		ACLMessage msg = myAgent.receive(mt);
		if(msg != null) {
			CreatorAgent agent = (CreatorAgent) myAgent;
			if(msg.getContent().equals("start"))
				agent.startCreation();
			else
				agent.stopCreation();
		}
		else
			block();
	}
}
